<?php
/*
  $Id$

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2010 osCommerce

  Released under the GNU General Public License
*/

  if (!isset($process)) $process = false;
?>

  <div class="contentText">
    <table border="0" width="100%" cellspacing="0" cellpadding="2">

<?php
  if (ACCOUNT_GENDER == 'true') {
    if (isset($gender)) {
      $male = ($gender == 'm') ? true : false;
      $female = ($gender == 'f') ? true : false;
    } else {
      $male = false;
      $female = false;
    }
?>

    <tr>
      <td class="fieldKey"><?php echo ENTRY_GENDER; ?></td>
      <td class="fieldValue"><?php echo tep_draw_radio_field('gender', 'm', $male) . '&nbsp;&nbsp;' . MALE . '&nbsp;&nbsp;' . tep_draw_radio_field('gender', 'f', $female) . '&nbsp;&nbsp;' . FEMALE . '&nbsp;' . (tep_not_null(ENTRY_GENDER_TEXT) ? '<span class="inputRequirement">' . ENTRY_GENDER_TEXT . '</span>': ''); ?></td>
    </tr>

<?php
  }
?>

    <tr>
      <td class="fieldKey"><?php echo ENTRY_FIRST_NAME; ?></td>
      <td class="fieldValue"><?php echo tep_draw_input_field('firstname') . '&nbsp;' . (tep_not_null(ENTRY_FIRST_NAME_TEXT) ? '<span class="inputRequirement">' . ENTRY_FIRST_NAME_TEXT . '</span>': ''); ?></td>
    </tr>
    <tr>
      <td class="fieldKey"><?php echo ENTRY_LAST_NAME; ?></td>
      <td class="fieldValue"><?php echo tep_draw_input_field('lastname') . '&nbsp;' . (tep_not_null(ENTRY_LAST_NAME_TEXT) ? '<span class="inputRequirement">' . ENTRY_LAST_NAME_TEXT . '</span>': ''); ?></td>
    </tr>

<?php
  if (ACCOUNT_COMPANY == 'true') {
?>

    <tr>
      <td class="fieldKey"><?php echo ENTRY_COMPANY; ?></td>
      <td class="fieldValue"><?php echo tep_draw_input_field('company') . '&nbsp;' . (tep_not_null(ENTRY_COMPANY_TEXT) ? '<span class="inputRequirement">' . ENTRY_COMPANY_TEXT . '</span>': ''); ?></td>
    </tr>

<?php
  }
?>

    <tr>
      <td class="fieldKey"><?php echo ENTRY_STREET_ADDRESS; ?></td>
      <td class="fieldValue"><?php echo tep_draw_input_field('street_address') . '&nbsp;' . (tep_not_null(ENTRY_STREET_ADDRESS_TEXT) ? '<span class="inputRequirement">' . ENTRY_STREET_ADDRESS_TEXT . '</span>': ''); ?></td>
    </tr>

<?php
  if (ACCOUNT_SUBURB == 'true') {
?>

    <tr>
      <td class="fieldKey"><?php echo ENTRY_SUBURB; ?></td>
      <td class="fieldValue"><?php echo tep_draw_input_field('suburb') . '&nbsp;' . (tep_not_null(ENTRY_SUBURB_TEXT) ? '<span class="inputRequirement">' . ENTRY_SUBURB_TEXT . '</span>': ''); ?></td>
    </tr>

<?php
  }
?>

    <tr>
      <td class="fieldKey"><?php echo ENTRY_POST_CODE; ?></td>
      <td class="fieldValue"><?php echo tep_draw_input_field('postcode') . '&nbsp;' . (tep_not_null(ENTRY_POST_CODE_TEXT) ? '<span class="inputRequirement">' . ENTRY_POST_CODE_TEXT . '</span>': ''); ?></td>
    </tr>
    <tr>
      <td class="fieldKey"><?php echo ENTRY_CITY; ?></td>
      <td class="fieldValue"><?php echo tep_draw_input_field('city') . '&nbsp;' . (tep_not_null(ENTRY_CITY_TEXT) ? '<span class="inputRequirement">' . ENTRY_CITY_TEXT . '</span>': ''); ?></td>
    </tr>

<?php
					  $zones_array = array();
					  $country_id_for = array();
					  if (ACCOUNT_STATE == 'true') {
					?>
								  <tr>
									<td class="main"><?php echo ENTRY_STATE; ?></td>
									<td class="main">
					<?php
						$select_zones_query = tep_db_query("SELECT c.countries_id, c.countries_iso_code_2, z.zone_name, z.zone_code FROM countries c, zones z WHERE c.countries_id = z.zone_country_id ORDER BY z.zone_country_id, z.zone_name");
						while ($zone_option = tep_db_fetch_array($select_zones_query)) {
						  $country_with_zone_code = $zone_option['countries_iso_code_2'];

						  // if this is the first time that we've seen this country,
						  if ( ! is_array($zones_array[$country_with_zone_code]) ) {
							// initialize an array for it with a blank default value
							$zones_array[$country_with_zone_code] 
							  = array(array('id'   => '', 
											'text' => PLEASE_SELECT_A_STATE));
							// save the country code to id mapping for use with the javascript later
							$country_id_for[$country_with_zone_code] = $zone_option['countries_id'];
						  }

						  $zones_array[$country_with_zone_code][] = array('id'   => $zone_option['zone_code'], 
																		  'text' => $zone_option['zone_name']);
						}
						foreach ( $zones_array as $country_with_zone_code => $country_zones_array) {
						  if ( count($country_zones_array) > 2 ) {
							echo tep_draw_pull_down_menu($country_with_zone_code . '_state', $country_zones_array, $state, 'style="display: none"');
						  } else {
							echo tep_draw_input_field($country_with_zone_code . '_state', $country_zones_array[1]['id'], 'readonly="readonly" style="display: none"');
						  }
						}
						echo tep_draw_input_field('state');

						if (tep_not_null(ENTRY_STATE_TEXT)) echo '&nbsp;<span class="inputRequirement">' . ENTRY_STATE_TEXT . '</span>';
					?>
									</td>
								  </tr>
					<?php
					  }
					?>
					  <tr>
						<td class="main"><?php echo ENTRY_COUNTRY; ?></td>
						<td class="main"><?php echo tep_get_country_list('country', $country) . '&nbsp;' . (tep_not_null(ENTRY_COUNTRY_TEXT) ? '<span class="inputRequirement">' . ENTRY_COUNTRY_TEXT . '</span>': ''); ?></td>
					  </tr>
					</table>
</div>
